import {
  Entity,
  Column,
  PrimaryColumn,
  OneToOne,
  ManyToOne,
  JoinColumn
} from 'typeorm'

import { User, Post } from './index'

@Entity()
export class Comment {
  @PrimaryColumn({ unique: true })
  id: string

  @ManyToOne(() => Post, (post) => post.comments)
  post: Post

  @Column()
  content: string

  @OneToOne(() => User)
  @JoinColumn()
  user: User

  @OneToOne(() => User)
  @JoinColumn()
  reply: User
}
